# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=libusb-win32
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=1.4.0.0
pkgrel=1
pkgdesc='Port of libusb-0.1 under Windows (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('spdx:LGPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
url='https://github.com/mcuee/libusb-win32'
source=(https://github.com/mcuee/libusb-win32/archive/release_${pkgver}.zip)
sha256sums=('7c041cbdcd47a9ad6fe7ef20605c94480454d6d768946f133fc7d9db38e22de6')

prepare() {
    cd "${srcdir}"/${_realname}-release_${pkgver}/libusb

    sed -i "s/mdll/shared/g" Makefile
    sed -i 's/ -Werror//g' Makefile
}

build() {
    cd "${srcdir}"/${_realname}-release_${pkgver}/libusb

    make CC=cc CC86=cc dll
}

package() {
    cd "${srcdir}"/${_realname}-release_${pkgver}/libusb

    install -Dm755 libusb0.dll "${pkgdir}${MINGW_PREFIX}/bin/libusb0.dll"
    install -Dm644 libusb.a "${pkgdir}${MINGW_PREFIX}/lib/libusb0.dll.a"
    install -Dm644 src/lusb0_usb.h "${pkgdir}${MINGW_PREFIX}/include/lusb0_usb.h"
}
